import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

import Layout from '../views/Layout/index.vue'
import Login from '../views/Login/Login.vue'
import Home from '../views/Home'
import Goods from '../views/Goods'
import Advert from '../views/Advert'
import Order from '../views/Order'
import Params from '../views/Params'
//异步
// const Home = () => import('../views/Home');
// const Goods = () => import('../views/Goods');
// const Advert = () => import('../views/Advert');
// const Order = () => import('../views/Order');
// const Params = () => import('../views/Params');

const routes = [
  {
    path: '',
    component: Layout,
    children: [
      {
        path: '/',
        name: 'Home',
        component: Home,
      },
      {
        path: '/goods',
        name: 'Goods',
        component: Goods,
      },
      {
        path: '/advert',
        name: 'Advert',
        component: Advert,
      },
      {
        path: '/order',
        name: 'Order',
        component: Order,
        redirect: '/order/orderlist',//默认跳转
        children: [
          {
            path: '/order/orderlist',
            name: 'OrderList',
            component: () => import('../views/Order/OrderList'),
          },
          {
            path: '/order/orderback',
            name: 'OrderBack',
            component: () => import('../views/Order/OrderBack'),
          },
        ]
      },
      {
        path: '/params',
        name: 'Params',
        component: Params,
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: Login,
  },
]

const router = new VueRouter({
  routes
})

export default router
